//
//  HomeCollectionViewCell.m
//  RoadMaintain
//
//  Created by 岳学坤 on 2017/2/28.
//  Copyright © 2017年 岳学坤. All rights reserved.
//

#import "HomeCollectionViewCell.h"

@implementation HomeCollectionViewCell
- (instancetype)initWithFrame:(CGRect)frame{
    if (self = [super initWithFrame:frame]) {
        self.backgroundColor = Bai_Color;
        self.layer.borderColor = [Line_Color CGColor];
        self.layer.borderWidth = 0.5;
        
        self.img = [[UIImageView alloc]init];
        [self addSubview:self.img];
        [self.img mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.mas_equalTo(45*HeightRate);
            make.centerX.mas_equalTo(0);
            make.size.mas_equalTo(CGSizeMake(60*WidthRate, 60*WidthRate));
        }];
        
        self.title = [[UILabel alloc]init];
        self.title.textColor = Black_Color;
        self.title.text = @"维修通知";
        self.title.font = [UIFont systemFontOfSize:16*ZitiRate];
        self.title.textAlignment = 1;
        [self addSubview:self.title];
        [self.title mas_makeConstraints:^(MASConstraintMaker *make) {
            make.bottom.mas_equalTo(-50*HeightRate);
            make.centerX.mas_equalTo(0);
            make.size.mas_equalTo(CGSizeMake(125*WidthRate, 16*HeightRate));
        }];
        
        self.badgeLab = [[UILabel alloc]init];
        self.badgeLab.textColor = Bai_Color;
        self.badgeLab.backgroundColor = Hong_Color;
        self.badgeLab.text = @"9+";
        if (IsPad) {
               self.badgeLab.font = [UIFont systemFontOfSize:14*PadWidthRate];
            self.badgeLab.layer.cornerRadius = 12*PadWidthRate;
        }else{
        self.badgeLab.font = [UIFont systemFontOfSize:11*WidthRate];
        self.badgeLab.layer.cornerRadius = 9*WidthRate;
        }
        self.badgeLab.textAlignment = 1;
        self.badgeLab.layer.masksToBounds = YES;
        [self addSubview:self.badgeLab];

    }
    return self;
}
- (void)maintainNotiFrame{
     [self.badgeLab mas_updateConstraints:^(MASConstraintMaker *make) {
         if (IsPad) {
             make.width.mas_equalTo(24*PadWidthRate);
             make.height.mas_equalTo(24*PadWidthRate);
         }else{
         make.width.mas_equalTo(18*WidthRate);
         make.height.mas_equalTo(18*WidthRate);
         }
         make.centerX.equalTo(self.img.mas_centerX).offset(18*WidthRate);
         make.centerY.equalTo(self.img.mas_centerY).offset(-15*WidthRate);
     }];
}
- (void)diseaseGetFrame{
    [self.badgeLab mas_updateConstraints:^(MASConstraintMaker *make) {
        if (IsPad) {
            make.width.mas_equalTo(24*PadWidthRate);
            make.height.mas_equalTo(24*PadWidthRate);
        }else{
            make.width.mas_equalTo(18*WidthRate);
            make.height.mas_equalTo(18*WidthRate);
        }
        make.centerX.equalTo(self.img.mas_centerX).offset(18*WidthRate);
        make.centerY.equalTo(self.img.mas_centerY).offset(-15*WidthRate);
    }];
}
@end
